package dbz.domain.dtos;

import java.util.ArrayList;
import java.util.List;

import dbz.domain.attack.Attack;
import dbz.domain.attack.conditions.AttackCondition;
import dbz.domain.attack.conditions.KiLevelCondition;

public class AttackDTO {

	String name;
	String initialDamage;
	String kiLevelCondition;
	String[] conditions;
	
	public AttackDTO(Attack attack) {
		name = attack.getName();
		initialDamage = attack.getInitialDamage().toString();
		kiLevelCondition = attack.getKiLevelCondition().toString();
		conditions = getAttckConditions(attack);
	}

	private String[] getAttckConditions(Attack attack) {
		List<AttackCondition> conditions = attack.getConditions();
		List<String> conditionsToAdd = new ArrayList<String>();
		for(AttackCondition condition : conditions) {
			if(!(condition instanceof KiLevelCondition)) {
				conditionsToAdd.add(condition.getDescription());
			}
		}
		return conditionsToAdd.toArray(new String[0]);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getInitialDamage() {
		return initialDamage;
	}

	public void setInitialDamage(String initialDamage) {
		this.initialDamage = initialDamage;
	}

	public String getKiLevelCondition() {
		return kiLevelCondition;
	}

	public void setKiLevelCondition(String kiLevelCondition) {
		this.kiLevelCondition = kiLevelCondition;
	}

	public String[] getConditions() {
		return conditions;
	}

	public void setConditions(String[] conditions) {
		this.conditions = conditions;
	}
}
